<template>
	<view class="content">
		<view class="section-0">
			<view class="section-body">
				<view class="peoject-name">
					<view class="title">项目名称</view>
					<view class="name">
						<text>{{name}}</text>
						<!-- <view class="iconfont icon-xiangyou1"></view> -->
					</view>
				</view>
				<timeLine :list="list"></timeLine>
			</view>
		</view>
	</view>
</template>

<script>
	const riskMap = {
		work_type: {
			name: '作业类型',
			filter: (val) => val
		},
		risk_level: {
			name: '风险等级',
			filter: (val) => val
		},
		work_position: {
			name: '作业部位',
			filter: (val) => val
		},
		work_name: {
			name: '作业票名称',
			filter: (val) => val
		},
		address: {
			name: '地址位置',
			filter: (val) => val
		},
		start_time: {
			name: '计划开始时间',
			filter: (val) => val ? val.substring(0, 10) : '-'
		},
		end_time: {
			name: '计划完成时间',
			filter: (val) => val ? val.substring(0, 10) : '-'
		},
		start_time_real: {
			name: '实际开始时间',
			filter: (val) => val ? val.substring(0, 10) : '-'
		},
		end_time_real: {
			name: '实际完成时间',
			filter: (val) => val ? val.substring(0, 10) : '-'
		},
		gk_measure: {
			name: '管控措施',
			filter: (val) => val
		},
		lc_status: {
			name: '流程状态',
			filter: (val) => val
		},
		oper_time: {
			name: '导入时间',
			filter: (val) => val ? val.substring(0, 10) : '-'
		},
	}
	import {
		projectRiskInfoApi
	} from '@/api/statistics.js';
	import { mapGetters, mapActions} from 'vuex';
	import timeLine from '@/components/time_line/index.vue';
	export default {
		components: { timeLine },	
		data() {
			return {
				name: '',
				id: '',
				list: []
			};
		},
		methods:{
			go(item) {
				uni.navigateTo({
					url: '/pages/statistics/today/risk/info/detail/index'
				})
			},
			async fetchData() {
				uni.showLoading({
					title: '加载中...'
				});
				const {
					data
				} = await projectRiskInfoApi({
					id: this.id
				});
				uni.hideLoading();
				if (data.code === 1) {
					let arr = [];
					let res = data.data;
					for (let key in res) {
						let item = {};
						if (riskMap[key]) {
							item = {
								title: riskMap[key].name,
								content: {
									type: 'text',
									value: riskMap[key].filter(res[key])
								}
							}
							arr.push(item);
						}
					}
					this.list = arr;
				}
			}
		},
		onLoad(data) {
			this.id = JSON.parse(data.params).id
			this.name = JSON.parse(data.params).project_name;
		},
		onReady() {
			this.fetchData();
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		background-color: #fff;
	}
	.section-0{
		width: 100%;
		background-color: #3a5df5;
		.section-body{
			padding-top: 50rpx;
			.peoject-name{
				margin-bottom: 65rpx;
				width: 100%;
				height: 158rpx;
				background-color: #ffffff;
				border-radius: 35rpx;
				box-shadow: 0 0 20rpx 10rpx rgba(#bcbcb5, 0.17);
				.title{
					width: 533rpx;
					height: 50rpx;
					padding-top: 15rpx;
					line-height: 50rpx;
					border-bottom: solid 3rpx #f2f2f0;
					font-size: 26rpx;
					font-weight: normal;
					font-stretch: normal;
					letter-spacing: 0rpx;
					color: #8497ac;
					margin-left: 35rpx;
				}
				.name{
					box-sizing: border-box;
					padding: 0 35rpx;
					width: 100%;
					height: 80rpx;
					line-height: 80rpx;
					font-size: 26rpx;
					font-weight: normal;
					font-stretch: normal;
					letter-spacing: 0rpx;
					color: #46464a;
					.iconfont{
						float: right;
						font-size: 30rpx;
						color: #3b3c40;
					}
				}
			}
			box-sizing: border-box;
			width: 100%;
			padding-left: 40rpx;
			padding-right: 40rpx;
			padding-bottom: 50rpx;
			background-color: #fff;
			background-size: cover;
			background-repeat: no-repeat;
			border-top-left-radius: 50rpx;
			border-top-right-radius: 50rpx;
		}
	}
</style>